<div class="panel panel-default">
	<div class="panel-heading">
		<?php 
			$this->widget('zii.widgets.CBreadcrumbs',array(
				'links'=>array(
						'首台管理',
						'用户列表'
			)
			));
		?>
	</div>
	<div class="panel-body">
		<table class="table">
			<tr>
				<th>用户名</th>
				<th>email</th>
				<th>是否为管理员</th>
				<th>帐号状态</th>
				<th>最后登录时间</th>
				<th>最后登录IP</th>
				<th>操作</th>
			</tr>
			<?php foreach($userList as $v): ?>
			<tr>
				<td><?php echo $v->username; ?></td>
				<td><?php echo $v->email; ?></td>
				<td><?php echo $v->is_admin; ?></td>
				<td><?php echo $v->status; ?></td>
				<td><?php echo date('Y-m-d', $v->login_time); ?></td>
				<td><?php echo $v->login_ip; ?></td>
				<td>
					<a href="<?php echo $this->createUrl('user/edit', array('user_id'=>$v->user_id)); ?>">编辑</a>
					<a class="delete" href="<?php echo $this->createUrl('user/delete');?>" userId = "<?php echo $v->user_id;?>">删除</a>
				</td>
			</tr>
			<?php endforeach; ?>
		</table>
	</div>
</div>
<script>
	$(function(){
		$('.delete').click(function(){
			$this = $(this);
			var $c = confirm("确定要删除该用户吗？");
			if($c == false){
					return false;
				}
			$.ajax({
				method : 'POST',
				data : {'user_id' : $(this).attr('userId')},
				url : $(this).attr('href'),
				success : function(data){
					data = eval("("+data+")");
					if(data.code == 1){
						$this.parents('tr').remove();
						} else {
						alert(data.message);
							}
					}
				});
			return false;
			});
	
		});
</script>